package nowCoder;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * @Auther: zzx
 * @Date: 2024.03.24/3/10
 */
public class HJ101 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer[] x = new Integer[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        if (m == 0){
            Arrays.sort(x);
        }else {
            Arrays.sort(x, Comparator.reverseOrder());
        }
        for (int i = 0; i < n; i++) {
            System.out.print(x[i]+" ");
        }
    }
}
